package java_thinking.unit_21._21_5;

import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;

/**
 * @Desc:   jdk8 ConcurrentHashMap的死锁bug
 * @author: cww
 * @DateTime: 2020-04-02 23:20
 */

public class ConHashMapBug {

    public static void main(String[] args) {
        ConcurrentHashMap<String, Integer> map = new ConcurrentHashMap<>(16);
        map.computeIfAbsent(
                "AaAa",
                new Function<String, Integer>() {
                    @Override
                    public Integer apply(String key) {
                        return map.computeIfAbsent("BBBB", new Function<String, Integer>() {
                            @Override
                            public Integer apply(String key2) {
                                return 42;
                            }
                        });
                    }
                }
        );
    }


}
